import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class demo11 {

    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("./text.txt");){
          while(true) {
              byte[] buffer = new byte[1024];
              int n = inputStream.read(buffer);
              if (n ==-1) {
                  break;
              }
              //这个操作就会把硬盘中读到的数据,填充到buffer内存的字节数组中(一次IO就在尽可能填满)
              // 此处buffer形参当成了"输出型参数"
              for (int i = 0; i < n; i++) {
                  System.out.printf("0x%x\n", buffer[i]);
              }
          }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
